#define _CRT_SECURE_NO_WARNINGS  1

#include <iostream>
#include<string>
#include<vector>
using namespace std;


int main()
{
	int a;
	cin >> a;
	string s;
	vector<int> vc(a, -1);
	int left = 0;
	int cur = 0;
	int right = 3;
	for (int i = 0; i < a; i++)
	{
		vc[i] = i + 1;
	}
	while (cin >> s)
	{
		for (int i = 0; i < s.length(); i++)
		{
			if (cur == 0 && s[i] == 'U' && a > 4)
			{
				cur = a - 1;
				right = a - 1;
				left = right - 3;
			}
			else if (cur == a - 1 && s[i] == 'D')
			{
				cur = 0;
				left = 0;
				right = left + 3;
			}
			else if (cur <= a - 1 && s[i] == 'D')
			{
				if (cur == right)
				{
					right++;
					left++;
				}
				cur++;
			}
			else if (cur >= 0 && s[i] == 'U')
			{
				if (cur == left)
				{
					left--;
					right--;
				}
				cur--;
			}
		}
	}
	if (a < 4)
	{
		for (int j = 0; j < a; j++)
		{
			cout << vc[j] << ' ';
		}
		cout << endl;
		cout << vc[0];
	}
	else
	{
		for (int j = left; j < left + 4; j++)
		{
			cout << vc[j] << ' ';
		}
		cout << endl;
		cout << vc[cur];
	}
	return 0;
}
